package com.cds.alert.action;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.cds.alert.ibatis.Criteria;
import com.cds.alert.pojo.AlertAlarmMail;
import com.cds.alert.pojo.AlertLogMail;
import com.cds.alert.pojo.AlertLogUrl;
import com.cds.alert.service.AlertLogUrlService;
import com.google.common.collect.Maps;
import com.opensymphony.xwork2.Preparable;

public class AlertLogUrlAction extends BaseAction implements Preparable {
	private static final long serialVersionUID = 6776558938712115191L;
	private List<AlertLogUrl> alertLogUrls;
	private AlertLogUrl alertLogUrl;
	private Long id;
	// 是否已读
	private String read;
	@Autowired
	private AlertLogUrlService alertLogUrlService;

	private Integer maxLength = 30;

	public void prepare() {
		if (getRequest().getMethod().equalsIgnoreCase("post")
				&& (!"".equals(getRequest().getParameter("alertLogMail.id")))) {
			// alertLogUrl = alertLogUrlService.selectByPrimaryKey(id);
		}
	}

	public List<AlertLogUrl> getAlertLogUrls() {
		return alertLogUrls;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getRead() {
		return read;
	}

	public void setRead(String read) {
		this.read = read;
	}

	public AlertLogUrl getAlertLogUrl() {
		return alertLogUrl;
	}

	public void setAlertLogUrl(AlertLogUrl alertLogUrl) {
		this.alertLogUrl = alertLogUrl;
	}

	public String delete() {

		return SUCCESS;
	}

	public String edit() throws IOException {

		return SUCCESS;
	}

	public String execute() {
		return SUCCESS;
	}

	public String cancel() {
		if (!"list".equals(from)) {
			return "home";
		}
		return "cancel";
	}

	public String save() throws Exception {
		return SUCCESS;
	}

	/** 网站访问日志 */
	public String list() {
		Criteria criteria = new Criteria();
		criteria.setMysqlOffset(0);
		criteria.setMysqlLength(maxLength);
		alertLogUrls = alertLogUrlService.queryByExample(criteria);
		return SUCCESS;
	}
}
